home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / misc / elcheapofax.lha / codes.c < prev    next >
C/C++ Source or Header  |  1993-03-31  |  715b  |  33 lines

  1. #include <stdio.h>
  2. #include "gdevdfg3.h"
  3.  
  4. void
  5. dumptable(struct tableentry *t, int size, char *descr)
  6. {
  7.     printf("%s:\n", descr);
  8.     while (size > 0) {
  9.     unsigned int m;
  10.  
  11.     m = 1 << (t->length - 1);
  12.     while (m) {
  13.         putchar((t->code & m)? '1' : '0');
  14.         m >>= 1;
  15.     }
  16.     printf("%*d %s\n", 20 - t->length, t->count, descr);
  17.     t++;
  18.     size--;
  19.     }
  20. }
  21.  
  22. int
  23. main(int argc, char **argv)
  24. {
  25. #define SZ(table)   (sizeof(table)/sizeof(table[0]))
  26.     dumptable(twtable, SZ(twtable), "white run length");
  27.     dumptable(mwtable, SZ(mwtable), "white run length");
  28.     dumptable(tbtable, SZ(tbtable), "black run length");
  29.     dumptable(mbtable, SZ(mbtable), "black run length");
  30.     dumptable(extable, SZ(extable), "extended");
  31. }
  32.  
  33.